#include "stdafx.h"
#include "RandomNoise.h"

#include "../../../Framework/Toolkit.h"

#include <stdlib.h>

using namespace Framework;

namespace MyGame {

RandomNoise::RandomNoise(void) {
    this->minHeight = 0.0f;
    this->maxHeight = 1.0f;
}

RandomNoise::~RandomNoise(void) {
}

FLOAT RandomNoise::GetMaxHeight() const {
    return this->maxHeight;
}

void RandomNoise::SetMaxHeight(FLOAT val) {
    this->maxHeight = val;
}

FLOAT RandomNoise::GetMinHeight() const {
    return this->minHeight;
}

void RandomNoise::SetMinHeight(FLOAT val) {
    this->minHeight = val;
}

void RandomNoise::Generate(HeightMap* heightMap) {
    FLOAT** map = heightMap->GetMap();
    int length = heightMap->GetLength();
    int width = heightMap->GetWidth();

    for (int h = 0; h < width; ++h) {
        for (int w = 0; w < length; ++w) {
            map[h][w] = (FLOAT)Toolkit::RandomFloat(this->minHeight, this->maxHeight);
        }
    }
}

}
